package 面向对象初级.方法.再谈方法;

import 面向对象初级.方法.课堂练习.MyDate;

public class AssignNewObject {
    public void swap(MyDate my){
        my=new MyDate();
        int temp=my.x;
        my.x=my.y;
        my.y=temp;
    }

    public static void main(String[] args) {
        AssignNewObject tools = new AssignNewObject();
        MyDate date=new MyDate();
        date.x=1;
        date.y=2;
        System.out.println("交换之前：x="+date.x+",y="+date.y);
        tools.swap(date);//调用完之后，x与y的值交换?
        System.out.println("交换之后：x="+date.x+",y="+date.y);
    }
}

class MaDate{
    int x;
    int t;
}
